(function(){
    function JobDetail(){
        var breadcrumb = new App.models.Breadcrumb({
            prefix: [
                {text: '任务管理', anchor: '/job'}
            ],
            curr: '任务列表'
        });

        var MainView = Backbone.View.extend({
            // el与initialize一样是bk的关键字, 不能重命名为其它
            el: '#page-cnt',
            template:  _.template($("#tpl-job-detail").html()),
            events: {},
            initialize: function() {
                // backbone的事件总线机制, 子视图之间可以由总线上报到主视图再与其他子视图通信
                this.eventBus = _.extend({}, Backbone.Events);
                // 创建面包屑视图
                this.breadcrumbView = new App.views.BreadcrumbView({
                    model: breadcrumb
                });
                this.render();
            },
            render: function(){
                this.$el.html(this.template());
                // 只有模板渲染后才能加载表格插件
                this.tableView = new App.views.BaseTableView({
                    columns: [
                        {field: 'minionId', title: 'minionId'},
                        {field: 'cmd', title: '执行命令'},
                        {field: 'target', title: '目标节点'},
                        {field: 'status', title: '状态'},
                        {field: 'result', title: '结果'},
                    ],
                    opts: {
                        el: '#job-detail .job-detail-list',
                        url: App.apiList.job.query,
                        queryParams: function(params){
                            params.jid = App.xbox.jid;
                            return params;
                        },
                        toolbar: '#job-detail .toolbar',
                    },
                    eventBus: this.eventBus
                });
            },
        });
        var mainView = new MainView();
        console.log('job start');
    }
    App.modules.JobDetail = JobDetail;
})();